﻿namespace QLPhongKham.UC
{
    using DevExpress.Data;
    using DevExpress.Utils;
    using DevExpress.XtraBars;
    using DevExpress.XtraEditors;
    using DevExpress.XtraEditors.Controls;
    using DevExpress.XtraEditors.Mask;
    using DevExpress.XtraEditors.Repository;
    using DevExpress.XtraGrid;
    using DevExpress.XtraGrid.Columns;
    using DevExpress.XtraGrid.Views.Base;
    using DevExpress.XtraGrid.Views.Grid;
    using DevExpress.XtraTab;
    using QLPhongKham.Access;
    using QLPhongKham.Access.Duoc;
    using QLPhongKham.BaseClass.Duoc;
    using QLPhongKham.Report;
    using System;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Windows.Forms;
    using UserControls;

    public class ucd_xuatkho_banle_kkedon_ll : XtraUserControl
    {
        private dtoDXuatBanLe _dtobanle;
        private int _iiddangnhap;
        private DXuatBanLe _xuatban;
        private General _xuli;
        private Bar bar1;
        private BarCheckItem barCheckItem1;
        private BarCheckItem barCheckItem2;
        private BarDockControl barDockControlBottom;
        private BarDockControl barDockControlLeft;
        private BarDockControl barDockControlRight;
        private BarDockControl barDockControlTop;
        private BarEditItem barEditItem1;
        private BarEditItem barEditItem2;
        private BarEditItem barEditItem3;
        private BarEditItem barEditItem4;
        private BarEditItem barEditItem5;
        private BarManager barManager1;
        private BarSubItem barSubItem1;
        private BarButtonItem bbiboqua;
        private BarButtonItem bbiinphieu;
        private BarButtonItem bbiketthuc;
        private BarButtonItem bbiluu;
        private BarEditItem bbithuockhongkedon;
        private BarEditItem bbixemtruocin;
        private SimpleButton btnthem;
        private SimpleButton btnxoa;
        private LookUpEdit cbbdonggoi;
        private LookUpEdit cbbnhomkh;
        private IContainer components;
        private ctrdanhsach ctrdanhsach_vp;
        private GridControl gridds;
        private GridColumn gridds_dongia;
        private GridColumn gridds_dvt;
        private GridColumn gridds_giaban;
        private GridColumn gridds_handung;
        private GridColumn gridds_hangsx;
        private GridColumn gridds_id;
        private GridColumn gridds_idnhapct;
        private GridColumn gridds_idvitrikho;
        private GridColumn gridds_losx;
        private GridColumn gridds_ma;
        private GridColumn gridds_slxuat;
        private GridColumn gridds_soluong;
        private GridColumn gridds_ten;
        private GridColumn gridds_tenhoatchat;
        private GridColumn gridds_tenvitrikho;
        private GridColumn gridds_thanhtien;
        private GridColumn gridds_thue;
        private GridColumn gridds_tongtien;
        private GridView gridView1;
        private GroupControl groupControl1;
        private GroupControl groupControl2;
        private Label label1;
        private Label label14;
        private Label label19;
        private Label label2;
        private Label label20;
        private Label label24;
        private Label label28;
        private Label label3;
        private Label label9;
        private Label lblmaso;
        private NumericUpDown nummiengiam;
        private RepositoryItemCheckEdit repositoryItemCheckEdit1;
        private RepositoryItemCheckEdit repositoryItemCheckEdit2;
        private RepositoryItemCheckEdit repositoryItemCheckEdit3;
        private RepositoryItemCheckEdit repositoryItemCheckEdit4;
        private RepositoryItemTextEdit repositoryItemTextEdit1;
        private RepositoryItemTextEdit repositoryItemTextEdit2;
        private RepositoryItemTextEdit repositoryItemTextEdit3;
        private RepositoryItemTextEdit repositoryItemTextEdit4;
        private StandaloneBarDockControl standaloneBarDockControl1;
        private UCTextBoxNumeric tbnumsoluong;
        private UCTextBoxNumeric tbnumtongmiengiam;
        private UCTextBoxNumeric tbnumtongthucthu;
        private UCTextBoxNumeric tbnumtongtien;
        private TextEdit txtdvt;
        private TextEdit txtma;
        private TextEdit txtsophieu;
        private TextEdit txtten;
        private TextEdit txttenhoatchat;

        public ucd_xuatkho_banle_kkedon_ll()
        {
            this._iiddangnhap = 0;
            this.components = null;
            this.InitializeComponent();
            this._xuli = new General();
            this._dtobanle = new dtoDXuatBanLe(this._xuli.pConFigData);
        }

        public ucd_xuatkho_banle_kkedon_ll(General xuli, int iddangnhap)
        {
            this._iiddangnhap = 0;
            this.components = null;
            this.InitializeComponent();
            this._xuli = xuli;
            this._iiddangnhap = iddangnhap;
            this._dtobanle = new dtoDXuatBanLe(this._xuli.pConFigData);
        }

        public ucd_xuatkho_banle_kkedon_ll(General xuli, dtoDXuatBanLe dtoxuatban, int iddangnhap)
        {
            this._iiddangnhap = 0;
            this.components = null;
            this.InitializeComponent();
            this._xuli = xuli;
            this._dtobanle = dtoxuatban;
            this._iiddangnhap = iddangnhap;
        }

        private void bbiboqua_ItemClick(object sender, ItemClickEventArgs e)
        {
            this.btnboqua_Click(null, null);
        }

        private void bbiinphieu_ItemClick(object sender, ItemClickEventArgs e)
        {
            this.btnin_Click(null, null);
        }

        private void bbiketthuc_ItemClick(object sender, ItemClickEventArgs e)
        {
            this.btnketthuc_Click(null, null);
        }

        private void bbiluu_ItemClick(object sender, ItemClickEventArgs e)
        {
            this.btnluu_Click(null, null);
        }

        private void bbithuockhongkedon_ItemClick(object sender, ItemClickEventArgs e)
        {
        }

        private void btnboqua_Click(object sender, EventArgs e)
        {
            if (this.bbiboqua.Visibility != BarItemVisibility.Never)
            {
                this.f_Control_enable(false);
            }
        }

        private void btnhuy_Click(object sender, EventArgs e)
        {
            if (this.txtsophieu.Tag.ToString() != "0")
            {
                dtoDXuatBanLe xuatban = new dtoDXuatBanLe(this._xuli.pConFigData) {
                    pID = long.Parse(this.txtsophieu.Tag.ToString())
                };
                xuatban.Load();
                if (!this._xuatban.f_huy_xuatbanle(xuatban))
                {
                    MessageBox.Show("Hủy kh\x00f4ng th\x00e0nh c\x00f4ng.", "Th\x00f4ng b\x00e1o");
                }
                else
                {
                    MessageBox.Show("Hủy th\x00e0nh c\x00f4ng.", "Th\x00f4ng b\x00e1o");
                    this.f_setcontrol_xuatbanle(long.Parse(this.txtsophieu.Tag.ToString()));
                    this.f_loaddata_xuatbanlect(long.Parse(this.txtsophieu.Tag.ToString()));
                    this.f_Control_enable(false);
                }
            }
        }

        private void btnin_Click(object sender, EventArgs e)
        {
            if (this.bbiinphieu.Visibility != BarItemVisibility.Never)
            {
                DataTable table = this._xuatban.f_loaddata_xuatban(long.Parse(this.txtsophieu.Tag.ToString()), "", "");
                table.TableName = "sophieu";
                DataTable table2 = this._xuatban.f_loaddata_xuatbanct(long.Parse(this.txtsophieu.Tag.ToString()));
                table2.TableName = "chitiet";
                table2.Columns.Add("sophieu");
                table2.Columns.Add("tennguoidangnhap");
                table2.Columns.Add("hoten");
                table2.Columns.Add("gioitinh");
                table2.Columns.Add("namsinh");
                table2.Columns.Add("diachi");
                table2.Columns.Add("solanin");
                for (int i = 0; i < table2.Rows.Count; i++)
                {
                    table2.Rows[i]["sophieu"] = this.txtsophieu.Text;
                    table2.Rows[i]["tennguoidangnhap"] = table.Rows[0]["tennguoidangnhap"].ToString();
                    table2.Rows[i]["hoten"] = "";
                    table2.Rows[i]["gioitinh"] = "nam";
                    table2.Rows[i]["namsinh"] = 0;
                    table2.Rows[i]["diachi"] = "";
                    table2.Rows[i]["solanin"] = table.Rows[0]["solanin"].ToString();
                }
                DataSet data = new DataSet();
                data.Tables.Add(table2.Copy());
                data.WriteXml("dataxml//d_inphieuxuatban_khongkedon.xml", XmlWriteMode.WriteSchema);
                XtraReport1 report = new XtraReport1();
                try
                {
                    bool editValue = (bool) this.bbixemtruocin.EditValue;
                    report.bPrinting = !editValue;
                }
                catch
                {
                }
                report.f_load(data, "repx_d_in_phieuxuatban_khongkedon.repx");
                if (report.pPrintingCount > 0)
                {
                    this._dtobanle = new dtoDXuatBanLe(this._xuli.pConFigData);
                    this._dtobanle.pID = long.Parse(this.txtsophieu.Tag.ToString());
                    this._dtobanle.Load();
                    this._dtobanle.pSOLANIN += report.pPrintingCount;
                    this._dtobanle.Update();
                }
            }
        }

        private void btnketthuc_Click(object sender, EventArgs e)
        {
            try
            {
                XtraTabPage parent = (XtraTabPage) base.Parent;
                XtraTabControl control = (XtraTabControl) parent.Parent;
                control.TabPages.Remove(parent);
            }
            catch
            {
                XtraUserControl control2 = (XtraUserControl) base.Parent;
                control2.Controls.Remove(this);
            }
        }

        private void btnluu_Click(object sender, EventArgs e)
        {
            if (this.bbiluu.Visibility != BarItemVisibility.Never)
            {
                dtoDXuatBanLeCT ect = new dtoDXuatBanLeCT(this._xuli.pConFigData);
                DataTable dataSource = (DataTable) this.gridds.DataSource;
                dataSource.AcceptChanges();
                for (int i = 0; i < (dataSource.Rows.Count - 1); i++)
                {
                    for (int k = i + 1; k < dataSource.Rows.Count; k++)
                    {
                        if (dataSource.Rows[i][this.gridds_id.FieldName].ToString() == dataSource.Rows[k][this.gridds_id.FieldName].ToString())
                        {
                            dataSource.Rows[i][this.gridds_soluong.FieldName] = decimal.Parse(dataSource.Rows[i][this.gridds_soluong.FieldName].ToString()) + decimal.Parse(dataSource.Rows[k][this.gridds_soluong.FieldName].ToString());
                            dataSource.Rows.RemoveAt(k--);
                        }
                    }
                }
                dtoDXuatBanLeCT[] chitiet = new dtoDXuatBanLeCT[dataSource.Rows.Count];
                for (int j = 0; j < dataSource.Rows.Count; j++)
                {
                    ect = new dtoDXuatBanLeCT(this._xuli.pConFigData);
                    try
                    {
                        ect.pDONGIA = decimal.Parse(dataSource.Rows[j][this.gridds_dongia.FieldName].ToString());
                    }
                    catch
                    {
                        ect.pDONGIA = 0M;
                    }
                    ect.pSOLUONG = decimal.Parse(dataSource.Rows[j][this.gridds_soluong.FieldName].ToString());
                    ect.pIDDUOCPHAM = int.Parse(dataSource.Rows[j][this.gridds_id.FieldName].ToString());
                    ect.pIDXUATKHOBANLE = long.Parse(this.txtsophieu.Tag.ToString());
                    ect.pIDDANGNHAP = this._iiddangnhap;
                    ect.pTHUE = decimal.Parse(dataSource.Rows[j][this.gridds_thue.FieldName].ToString());
                    chitiet[j] = ect;
                }
                dtoDXuatBanLe xuatban = new dtoDXuatBanLe(this._xuli.pConFigData) {
                    pHOTEN = "",
                    pID = long.Parse(this.txtsophieu.Tag.ToString()),
                    pIDDANGNHAP = this._iiddangnhap,
                    pIDGIOITINH = 0,
                    pIDLOAIXUAT = HangSo.LoaiXuatKho.enLoaiXuatKho.XuatBanKhongKeDon.GetHashCode(),
                    pNAMSINH = "0",
                    pNGAY = DateTime.Now.ToString("dd/MM/yyyy HH:mm"),
                    pTENMAYTINH = Environment.MachineName
                };
                try
                {
                    xuatban.pSOPHIEU = long.Parse(this.txtsophieu.Text);
                }
                catch
                {
                    xuatban.pSOPHIEU = 0L;
                }
                xuatban.pTONGTIEN = this.tbnumtongtien.Values;
                xuatban.pDIACHI = "";
                xuatban.pCHIETKHAU = this.nummiengiam.Value;
                xuatban.pIDNHOMKHACHHANG = this.cbbnhomkh.EditValue.GetHashCode();
                xuatban.pKIHIEU = this.txtsophieu.Text;
                DXuatBanLe le2 = new DXuatBanLe(this._xuli.pConFigData);
                if (xuatban.pID == 0L)
                {
                    xuatban.pKIHIEU = this._xuatban.f_get_capmaphieu("PKKD");
                    xuatban.pSOPHIEU = this._xuatban.f_get_capsophieu();
                    this.txtsophieu.Tag = le2.f_insert_xuatbanle(xuatban, chitiet, (HangSo.NhomKhachHang.enNhomKhachHang) this.cbbnhomkh.EditValue).ToString();
                    if (this.txtsophieu.Tag.ToString() == "0")
                    {
                        MessageBox.Show("Kh\x00f4ng lưu được th\x00f4ng tin phiếu xuất kh\x00f4ng k\x00ea đơn.", "Th\x00f4ng b\x00e1o", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                        return;
                    }
                }
                else
                {
                    this.txtsophieu.Tag = le2.f_update_xuatbanle(xuatban, chitiet, (HangSo.NhomKhachHang.enNhomKhachHang) this.cbbnhomkh.EditValue).ToString();
                    if (this.txtsophieu.Tag.ToString() == "0")
                    {
                        MessageBox.Show("Kh\x00f4ng lưu được th\x00f4ng tin xuất kh\x00f4ng k\x00ea đơn.", "Th\x00f4ng b\x00e1o", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                        return;
                    }
                }
                this.f_setcontrol_xuatbanle(long.Parse(this.txtsophieu.Tag.ToString()));
                this.f_loaddata_xuatbanlect(long.Parse(this.txtsophieu.Tag.ToString()));
                this.f_Loaddata_dmvp();
                this.f_Control_enable(false);
            }
        }

        private void btnmoi_Click(object sender, EventArgs e)
        {
            this.f_Add_ChiTiet();
            this.f_Loadcontrol_dmvp(0L, "", "", "", "", 0M);
            this.f_Loadcontrol_xuatbanlechitiet(0L, 0M, 0M, 0M, 0M, 0M, 0M, "", DateTime.Now.ToString("dd/MM/yyyy"), "", "");
            base.ActiveControl = this.txtma;
        }

        private void btnmoi_Click_1(object sender, EventArgs e)
        {
            this.f_Control_enable(true);
            this.f_Loadcontrol_xuatbanle(0L, "", DateTime.Now.ToString("dd/MM/yyyy HH:mm"), "", 0, 0, DateTime.Now.Year, "", 0M, 0M, 0M, 0M, 0);
            this.f_loaddata_xuatbanlect(0L);
            this.f_Loadcontrol_dmvp(0L, "", "", "", "", 0M);
            this.f_Loadcontrol_xuatbanlechitiet(0L, 0M, 0M, 0M, 0M, 0M, 0M, "", DateTime.Now.ToString("dd/MM/yyyy"), "", "");
            this.f_Loaddata_dmvp();
            this.txtma.Focus();
        }

        private void btnsua_Click(object sender, EventArgs e)
        {
            this.f_Control_enable(true);
            this.txtsophieu.Enabled = false;
            this.txtten.Focus();
        }

        private void btnxoa_Click(object sender, EventArgs e)
        {
            try
            {
                this.gridView1.DeleteSelectedRows();
            }
            catch
            {
            }
        }

        private void ctrdanhsach_vp_Validated(object sender, EventArgs e)
        {
            try
            {
                DataTable dongHienTai = this.ctrdanhsach_vp.DongHienTai;
                this.f_SetControl_dmsanpham(long.Parse(dongHienTai.Rows[0]["iddp"].ToString()));
            }
            catch
            {
            }
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void f_Add_ChiTiet()
        {
            if ((this.txtma.Tag != null) && (this.txtma.Tag.ToString() != "0"))
            {
                decimal values = this.tbnumsoluong.Values;
                int idduocpham = int.Parse(this.txtma.Tag.ToString());
                DataTable dataSource = (DataTable) this.gridds.DataSource;
                dataSource.AcceptChanges();
                if (dataSource.Select(this.gridds_id.FieldName + "=" + idduocpham).Length > 0)
                {
                    if (MessageBox.Show("T\x00ean dược phẩm '" + this.txtten.Text.ToUpper() + "' đ\x00e3 tồn tại.\nBạn c\x00f3 muốn cập nhật th\x00eam số lượng của dược phẩm n\x00e0y kh\x00f4ng?", "Th\x00f4ng b\x00e1o", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) != DialogResult.Yes)
                    {
                        return;
                    }
                    for (int j = 0; j < dataSource.Rows.Count; j++)
                    {
                        if (dataSource.Rows[j][this.gridds_id.FieldName].ToString() == idduocpham.ToString())
                        {
                            values += decimal.Parse(dataSource.Rows[j][this.gridds_soluong.FieldName].ToString());
                            dataSource.Rows.RemoveAt(j--);
                        }
                    }
                }
                dataSource.AcceptChanges();
                DataTable table2 = new DTonKho(this._xuli.pConFigData).f_load_tonkhochitiet(HangSo.NhomKhachHang.f_get_NhomKhachHang(Convert.ToInt32(this.cbbnhomkh.EditValue)), idduocpham).Tables[0];
                decimal num4 = 0M;
                decimal num5 = values;
                for (int i = 0; i < table2.Rows.Count; i++)
                {
                    num4 = 0M;
                    DataRow row = dataSource.NewRow();
                    dataSource.Rows.Add(row);
                    row[this.gridds_idnhapct.FieldName] = 0;
                    row[this.gridds_ma.FieldName] = this.txtma.Text;
                    row[this.gridds_ten.FieldName] = this.txtten.Text;
                    row[this.gridds_dvt.FieldName] = this.txtdvt.Text;
                    row[this.gridds_id.FieldName] = idduocpham;
                    row[this.gridds_thue.FieldName] = 0;
                    row[this.gridds_dongia.FieldName] = table2.Rows[i]["giaban"].ToString();
                    row[this.gridds_losx.FieldName] = table2.Rows[i]["losx"].ToString();
                    row[this.gridds_handung.FieldName] = table2.Rows[i]["handung"].ToString();
                    row[this.gridds_tenvitrikho.FieldName] = table2.Rows[i]["tenvitrikho"].ToString();
                    try
                    {
                        num4 = decimal.Parse(table2.Rows[i]["soluongton"].ToString());
                    }
                    catch
                    {
                    }
                    if ((num4 >= num5) && (num5 > 0M))
                    {
                        row[this.gridds_soluong.FieldName] = num5;
                        num5 = 0M;
                        row[this.gridds_thanhtien.FieldName] = decimal.Parse(row[this.gridds_dongia.FieldName].ToString()) * decimal.Parse(row[this.gridds_soluong.FieldName].ToString());
                        break;
                    }
                    row[this.gridds_soluong.FieldName] = num4;
                    num5 -= num4;
                    row[this.gridds_thanhtien.FieldName] = decimal.Parse(row[this.gridds_dongia.FieldName].ToString()) * decimal.Parse(row[this.gridds_soluong.FieldName].ToString());
                }
                if (num5 > 0M)
                {
                    MessageBox.Show("Số lượng nhập vượt qu\x00e1 số lượng tồn kho (" + (values - num5) + ")", "Th\x00f4ng b\x00e1o", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                this.gridds.DataSource = dataSource;
                this.f_tinhtongtien();
            }
        }

        private void f_Control_enable(bool chophep)
        {
            if (chophep)
            {
                this.bbiluu.Visibility = this.bbiboqua.Visibility = BarItemVisibility.Always;
                this.bbiketthuc.Visibility = this.bbiinphieu.Visibility = BarItemVisibility.Never;
            }
            else
            {
                this.bbiluu.Visibility = this.bbiboqua.Visibility = BarItemVisibility.Never;
                this.bbiketthuc.Visibility = this.bbiinphieu.Visibility = BarItemVisibility.Always;
            }
            this.btnthem.Enabled = this.btnxoa.Enabled = this.nummiengiam.Enabled = this.tbnumtongmiengiam.Enabled = chophep;
            this.cbbnhomkh.Properties.ReadOnly = !chophep;
        }

        private void f_load_nhomkh()
        {
            try
            {
                this.cbbnhomkh.Properties.DataSource = HangSo.NhomKhachHang.f_DanhSach();
                this.cbbnhomkh.Properties.DisplayMember = "ten";
                this.cbbnhomkh.Properties.ValueMember = "id";
                this.cbbnhomkh.ItemIndex = 0;
            }
            catch
            {
            }
        }

        private void f_Loadcontrol_dmvp(long id, string ma, string ten, string tenhoatchat, string dvt, decimal dongia)
        {
            this.txtma.Text = ma;
            this.txtma.Tag = id.ToString();
            this.txtten.Text = ten;
            this.txtdvt.Text = dvt;
            this.txttenhoatchat.Text = tenhoatchat;
            try
            {
                this.cbbdonggoi.Properties.DataSource = new DDuocPham().f_loaddata_dmdonggoi(Convert.ToInt32(id));
                this.cbbdonggoi.Properties.DisplayMember = "ten";
                this.cbbdonggoi.Properties.ValueMember = "id";
                this.cbbdonggoi.ItemIndex = 0;
            }
            catch
            {
            }
        }

        private void f_Loadcontrol_xuatbanle(long id, string sophieu, string ngay, string hoten, int gioitinh, int tuoi, int namsinh, string diachi, decimal miengiam, decimal tongmiengiam, decimal tongtien, decimal tongthucthu, int nhomkhachhang)
        {
            this.txtsophieu.Tag = id.ToString();
            this.txtsophieu.Text = sophieu;
            this.nummiengiam.Value = miengiam;
            this.tbnumtongmiengiam.Values = tongmiengiam;
            this.tbnumtongtien.Values = tongtien;
            this.tbnumtongthucthu.Values = tongthucthu;
            this.cbbnhomkh.EditValue = nhomkhachhang;
        }

        private void f_Loadcontrol_xuatbanlechitiet(long id, decimal soluong, decimal dongia, decimal sotien, decimal thue, decimal tienthue, decimal giaban, string losx, string handung, string hangsx, string tenvitrikho)
        {
            this.lblmaso.Tag = id.ToString();
            this.tbnumsoluong.Values = soluong;
        }

        private void f_Loaddata_dmvp()
        {
            try
            {
                this.ctrdanhsach_vp.SetDataSource = new DTonKho(this._xuli.pConFigData).f_load_tonkhotonghop().Tables[0];
                this.ctrdanhsach_vp.DanhSachCotHienThi = "madp,tendp,dvt,soluongton";
            }
            catch
            {
            }
        }

        private void f_loaddata_xuatbanlect(long idxuatban)
        {
            DataTable table = this._xuatban.f_loaddata_xuatbanct(idxuatban);
            this.gridds.DataSource = table;
            decimal num = 0M;
            for (int i = 0; i < table.Rows.Count; i++)
            {
                num += decimal.Parse(table.Rows[i][this.gridds_thanhtien.FieldName].ToString()) *(decimal.Parse(table.Rows[i][this.gridds_thue.FieldName].ToString()) / 100M+1);
            }
            this.tbnumtongtien.Values = num;
            this.nummiengiam_Validated(null, null);
        }

        private void f_loadinfo_chidinhchitiet(int indexrow)
        {
            try
            {
                this.f_Loadcontrol_dmvp(long.Parse(this.gridView1.GetRowCellValue(indexrow, this.gridds_id).ToString()), this.gridView1.GetRowCellValue(indexrow, this.gridds_ma).ToString(), this.gridView1.GetRowCellValue(indexrow, this.gridds_ten).ToString(), this.gridView1.GetRowCellValue(indexrow, this.gridds_tenhoatchat).ToString(), this.gridView1.GetRowCellValue(indexrow, this.gridds_dvt).ToString(), decimal.Parse(this.gridView1.GetRowCellValue(indexrow, this.gridds_dongia).ToString()));
                this.f_Loadcontrol_xuatbanlechitiet(long.Parse(this.gridView1.GetRowCellValue(indexrow, this.gridds_idnhapct).ToString()), decimal.Parse(this.gridView1.GetRowCellValue(indexrow, this.gridds_soluong).ToString()), decimal.Parse(this.gridView1.GetRowCellValue(indexrow, this.gridds_dongia).ToString()), decimal.Parse(this.gridView1.GetRowCellValue(indexrow, this.gridds_thanhtien).ToString()), decimal.Parse(this.gridView1.GetRowCellValue(indexrow, this.gridds_thue).ToString()), decimal.Parse(this.gridView1.GetRowCellValue(indexrow, this.gridds_thanhtien).ToString()), decimal.Parse(this.gridView1.GetRowCellValue(indexrow, this.gridds_giaban).ToString()), this.gridView1.GetRowCellValue(indexrow, this.gridds_losx).ToString(), this.gridView1.GetRowCellValue(indexrow, this.gridds_handung).ToString(), this.gridView1.GetRowCellValue(indexrow, this.gridds_hangsx).ToString(), this.gridView1.GetRowCellValue(indexrow, this.gridds_tenvitrikho).ToString());
            }
            catch
            {
            }
        }

        private void f_SetControl_dmsanpham(long idvp)
        {
            try
            {
                DataRow[] rowArray = this.ctrdanhsach_vp.SetDataSource.Select("iddp=" + idvp.ToString());
                this.f_Loadcontrol_dmvp(idvp, rowArray[0]["madp"].ToString(), rowArray[0]["tendp"].ToString(), rowArray[0]["tenhoatchat"].ToString(), rowArray[0]["dvt"].ToString(), decimal.Parse(rowArray[0]["giaban"].ToString()));
            }
            catch
            {
                this.f_Loadcontrol_dmvp(0L, "", "", "", "", 0M);
            }
        }

        private void f_setcontrol_xuatbanle(long id)
        {
            dtoDXuatBanLe le = new dtoDXuatBanLe(this._xuli.pConFigData) {
                pID = id
            };
            le.Load();
            try
            {
                decimal tongmiengiam = (le.pCHIETKHAU / 100M) * le.pTONGTIEN;
                this.f_Loadcontrol_xuatbanle(le.pID, le.pKIHIEU.ToString(), le.pNGAY, le.pHOTEN, le.pIDGIOITINH, DateTime.Now.Year - int.Parse(le.pNAMSINH), int.Parse(le.pNAMSINH), le.pDIACHI, le.pCHIETKHAU, tongmiengiam, le.pTONGTIEN, le.pTONGTIEN - tongmiengiam, le.pIDNHOMKHACHHANG);
            }
            catch
            {
                this.f_Loadcontrol_xuatbanle(0L, "", DateTime.Now.ToString("dd/MM/yyyy HH:mm"), "", HangSo.enGioiTinh.Nam.GetHashCode(), 0, DateTime.Now.Year, "", 0M, 0M, 0M, 0M, 0);
            }
        }

        private void f_tinhtongtien()
        {
            try
            {
                decimal num = 0M;
                DataTable dataSource = (DataTable) this.gridds.DataSource;
                for (int i = 0; i < dataSource.Rows.Count; i++)
                {
                    num += decimal.Parse(dataSource.Rows[i][this.gridds_thanhtien.FieldName].ToString());
                }
                this.tbnumtongtien.Values = num;
                decimal num3 = (this.nummiengiam.Value * num) / 100M;
                this.tbnumtongmiengiam.Values = num3;
                this.tbnumtongthucthu.Values = num - num3;
            }
            catch
            {
            }
        }

        private void gridView1_CustomSummaryCalculate(object sender, CustomSummaryEventArgs e)
        {
        }

        private void gridView1_FocusedRowChanged(object sender, FocusedRowChangedEventArgs e)
        {
            int indexrow = 0;
            try
            {
                if (this.gridView1.IsFocusedView)
                {
                    indexrow = this.gridView1.GetSelectedRows()[0];
                    this.f_loadinfo_chidinhchitiet(indexrow);
                }
            }
            catch
            {
            }
        }

        private void gridView1_RowCellStyle(object sender, RowCellStyleEventArgs e)
        {
        }

        private void InitializeComponent()
        {
            this.components = new Container();
            ComponentResourceManager manager = new ComponentResourceManager(typeof(ucd_xuatkho_banle_kkedon_ll));
            StyleFormatCondition condition = new StyleFormatCondition();
            this.gridds_dongia = new GridColumn();
            this.repositoryItemTextEdit2 = new RepositoryItemTextEdit();
            this.lblmaso = new Label();
            this.txtma = new TextEdit();
            this.txtten = new TextEdit();
            this.txtdvt = new TextEdit();
            this.btnthem = new SimpleButton();
            this.gridView1 = new GridView();
            this.gridds_ma = new GridColumn();
            this.gridds_ten = new GridColumn();
            this.gridds_dvt = new GridColumn();
            this.gridds_id = new GridColumn();
            this.gridds_soluong = new GridColumn();
            this.gridds_thanhtien = new GridColumn();
            this.gridds_idnhapct = new GridColumn();
            this.gridds_slxuat = new GridColumn();
            this.gridds_tenhoatchat = new GridColumn();
            this.gridds_giaban = new GridColumn();
            this.gridds_losx = new GridColumn();
            this.gridds_handung = new GridColumn();
            this.gridds_hangsx = new GridColumn();
            this.gridds_idvitrikho = new GridColumn();
            this.gridds_thue = new GridColumn();
            this.gridds_tongtien = new GridColumn();
            this.gridds_tenvitrikho = new GridColumn();
            this.gridds = new GridControl();
            this.label1 = new Label();
            this.txtsophieu = new TextEdit();
            this.ctrdanhsach_vp = new ctrdanhsach();
            this.txttenhoatchat = new TextEdit();
            this.label2 = new Label();
            this.label14 = new Label();
            this.tbnumsoluong = new UCTextBoxNumeric();
            this.label19 = new Label();
            this.tbnumtongtien = new UCTextBoxNumeric();
            this.label20 = new Label();
            this.tbnumtongthucthu = new UCTextBoxNumeric();
            this.btnxoa = new SimpleButton();
            this.tbnumtongmiengiam = new UCTextBoxNumeric();
            this.label9 = new Label();
            this.label3 = new Label();
            this.nummiengiam = new NumericUpDown();
            this.label24 = new Label();
            this.label28 = new Label();
            this.cbbnhomkh = new LookUpEdit();
            this.groupControl1 = new GroupControl();
            this.groupControl2 = new GroupControl();
            this.cbbdonggoi = new LookUpEdit();
            this.standaloneBarDockControl1 = new StandaloneBarDockControl();
            this.barManager1 = new BarManager(this.components);
            this.bar1 = new Bar();
            this.bbiluu = new BarButtonItem();
            this.bbiboqua = new BarButtonItem();
            this.bbiinphieu = new BarButtonItem();
            this.bbiketthuc = new BarButtonItem();
            this.bbixemtruocin = new BarEditItem();
            this.repositoryItemCheckEdit3 = new RepositoryItemCheckEdit();
            this.bbithuockhongkedon = new BarEditItem();
            this.repositoryItemCheckEdit4 = new RepositoryItemCheckEdit();
            this.barDockControlTop = new BarDockControl();
            this.barDockControlBottom = new BarDockControl();
            this.barDockControlLeft = new BarDockControl();
            this.barDockControlRight = new BarDockControl();
            this.barCheckItem1 = new BarCheckItem();
            this.barSubItem1 = new BarSubItem();
            this.barEditItem1 = new BarEditItem();
            this.repositoryItemCheckEdit1 = new RepositoryItemCheckEdit();
            this.barEditItem2 = new BarEditItem();
            this.repositoryItemCheckEdit2 = new RepositoryItemCheckEdit();
            this.barEditItem3 = new BarEditItem();
            this.repositoryItemTextEdit1 = new RepositoryItemTextEdit();
            this.barEditItem4 = new BarEditItem();
            this.repositoryItemTextEdit3 = new RepositoryItemTextEdit();
            this.barEditItem5 = new BarEditItem();
            this.repositoryItemTextEdit4 = new RepositoryItemTextEdit();
            this.barCheckItem2 = new BarCheckItem();
            this.repositoryItemTextEdit2.BeginInit();
            this.txtma.Properties.BeginInit();
            this.txtten.Properties.BeginInit();
            this.txtdvt.Properties.BeginInit();
            this.gridView1.BeginInit();
            this.gridds.BeginInit();
            this.txtsophieu.Properties.BeginInit();
            this.txttenhoatchat.Properties.BeginInit();
            this.nummiengiam.BeginInit();
            this.cbbnhomkh.Properties.BeginInit();
            this.groupControl1.BeginInit();
            this.groupControl1.SuspendLayout();
            this.groupControl2.BeginInit();
            this.groupControl2.SuspendLayout();
            this.cbbdonggoi.Properties.BeginInit();
            this.barManager1.BeginInit();
            this.repositoryItemCheckEdit3.BeginInit();
            this.repositoryItemCheckEdit4.BeginInit();
            this.repositoryItemCheckEdit1.BeginInit();
            this.repositoryItemCheckEdit2.BeginInit();
            this.repositoryItemTextEdit1.BeginInit();
            this.repositoryItemTextEdit3.BeginInit();
            this.repositoryItemTextEdit4.BeginInit();
            base.SuspendLayout();
            this.gridds_dongia.Caption = "Đơn gi\x00e1";
            this.gridds_dongia.ColumnEdit = this.repositoryItemTextEdit2;
            this.gridds_dongia.FieldName = "giaban";
            this.gridds_dongia.Name = "gridds_dongia";
            this.gridds_dongia.Visible = true;
            this.gridds_dongia.VisibleIndex = 3;
            this.gridds_dongia.Width = 0x42;
            this.repositoryItemTextEdit2.AutoHeight = false;
            this.repositoryItemTextEdit2.DisplayFormat.FormatString = "n0";
            this.repositoryItemTextEdit2.DisplayFormat.FormatType = FormatType.Numeric;
            this.repositoryItemTextEdit2.EditFormat.FormatType = FormatType.Numeric;
            this.repositoryItemTextEdit2.Mask.EditMask = "n0";
            this.repositoryItemTextEdit2.Mask.MaskType = MaskType.Numeric;
            this.repositoryItemTextEdit2.Name = "repositoryItemTextEdit2";
            this.lblmaso.Font = new Font("Tahoma", 10f);
            this.lblmaso.Location = new Point(4, 30);
            this.lblmaso.Name = "lblmaso";
            this.lblmaso.Size = new Size(0x60, 0x13);
            this.lblmaso.TabIndex = 2;
            this.lblmaso.Text = "Dược phẩm:";
            this.lblmaso.TextAlign = ContentAlignment.TopRight;
            this.txtma.Location = new Point(0x60, 0x1d);
            this.txtma.Name = "txtma";
            this.txtma.Properties.CharacterCasing = CharacterCasing.Upper;
            this.txtma.Size = new Size(0x36, 20);
            this.txtma.TabIndex = 12;
            this.txtma.KeyDown += new KeyEventHandler(this.ucDMSanPham_KeyDown);
            this.txtma.Validated += new EventHandler(this.txtma_Validated);
            this.txtten.Location = new Point(0x9a, 0x1d);
            this.txtten.Name = "txtten";
            this.txtten.Size = new Size(0x201, 20);
            this.txtten.TabIndex = 13;
            this.txtten.TextChanged += new EventHandler(this.txtten_TextChanged);
            this.txtten.Enter += new EventHandler(this.txtten_Enter);
            this.txtten.KeyDown += new KeyEventHandler(this.txtten_KeyDown);
            this.txtten.Validated += new EventHandler(this.txtten_Validated);
            this.txtdvt.EditValue = "";
            this.txtdvt.Enabled = false;
            this.txtdvt.Location = new Point(0xf7, 0x36);
            this.txtdvt.Name = "txtdvt";
            this.txtdvt.Size = new Size(40, 20);
            this.txtdvt.TabIndex = 20;
            this.txtdvt.KeyDown += new KeyEventHandler(this.ucDMSanPham_KeyDown);
            this.btnthem.Appearance.Options.UseTextOptions = true;
            this.btnthem.Appearance.TextOptions.HAlignment = HorzAlignment.Near;
            this.btnthem.Image = (Image) manager.GetObject("btnthem.Image");
            this.btnthem.Location = new Point(0x60, 0x53);
            this.btnthem.Name = "btnthem";
            this.btnthem.Size = new Size(0x4b, 0x17);
            this.btnthem.TabIndex = 0x1a;
            this.btnthem.Text = " &Th\x00eam [F2]";
            this.btnthem.Click += new EventHandler(this.btnmoi_Click);
            this.gridView1.Appearance.ColumnFilterButton.BackColor = Color.FromArgb(0xec, 0xe8, 0xc9);
            this.gridView1.Appearance.ColumnFilterButton.BorderColor = Color.FromArgb(0xec, 0xe8, 0xc9);
            this.gridView1.Appearance.ColumnFilterButton.ForeColor = Color.Black;
            this.gridView1.Appearance.ColumnFilterButton.Options.UseBackColor = true;
            this.gridView1.Appearance.ColumnFilterButton.Options.UseBorderColor = true;
            this.gridView1.Appearance.ColumnFilterButton.Options.UseForeColor = true;
            this.gridView1.Appearance.ColumnFilterButtonActive.BackColor = Color.FromArgb(0xdd, 0xe7, 0xea);
            this.gridView1.Appearance.ColumnFilterButtonActive.BorderColor = Color.FromArgb(0xdd, 0xe7, 0xea);
            this.gridView1.Appearance.ColumnFilterButtonActive.ForeColor = Color.Black;
            this.gridView1.Appearance.ColumnFilterButtonActive.Options.UseBackColor = true;
            this.gridView1.Appearance.ColumnFilterButtonActive.Options.UseBorderColor = true;
            this.gridView1.Appearance.ColumnFilterButtonActive.Options.UseForeColor = true;
            this.gridView1.Appearance.Empty.BackColor = Color.FromArgb(0xec, 0xe8, 0xc9);
            this.gridView1.Appearance.Empty.BackColor2 = Color.White;
            this.gridView1.Appearance.Empty.Options.UseBackColor = true;
            this.gridView1.Appearance.EvenRow.BackColor = Color.FromArgb(0xdd, 0xe7, 0xea);
            this.gridView1.Appearance.EvenRow.BorderColor = Color.FromArgb(0xdd, 0xe7, 0xea);
            this.gridView1.Appearance.EvenRow.ForeColor = Color.Black;
            this.gridView1.Appearance.EvenRow.Options.UseBackColor = true;
            this.gridView1.Appearance.EvenRow.Options.UseBorderColor = true;
            this.gridView1.Appearance.EvenRow.Options.UseForeColor = true;
            this.gridView1.Appearance.FilterCloseButton.BackColor = Color.FromArgb(0xd8, 0xd1, 0xb3);
            this.gridView1.Appearance.FilterCloseButton.BorderColor = Color.FromArgb(0xd8, 0xd1, 0xb3);
            this.gridView1.Appearance.FilterCloseButton.ForeColor = Color.Black;
            this.gridView1.Appearance.FilterCloseButton.Options.UseBackColor = true;
            this.gridView1.Appearance.FilterCloseButton.Options.UseBorderColor = true;
            this.gridView1.Appearance.FilterCloseButton.Options.UseForeColor = true;
            this.gridView1.Appearance.FilterPanel.BackColor = Color.FromArgb(0xec, 0xe8, 0xc9);
            this.gridView1.Appearance.FilterPanel.BackColor2 = Color.White;
            this.gridView1.Appearance.FilterPanel.ForeColor = Color.Black;
            this.gridView1.Appearance.FilterPanel.Options.UseBackColor = true;
            this.gridView1.Appearance.FilterPanel.Options.UseForeColor = true;
            this.gridView1.Appearance.FixedLine.BackColor = Color.FromArgb(0x7a, 0x72, 0x71);
            this.gridView1.Appearance.FixedLine.Options.UseBackColor = true;
            this.gridView1.Appearance.FocusedCell.BackColor = Color.White;
            this.gridView1.Appearance.FocusedCell.ForeColor = Color.Black;
            this.gridView1.Appearance.FocusedCell.Options.UseBackColor = true;
            this.gridView1.Appearance.FocusedCell.Options.UseForeColor = true;
            this.gridView1.Appearance.FocusedRow.BackColor = Color.FromArgb(200, 0xc0, 0x9d);
            this.gridView1.Appearance.FocusedRow.BorderColor = Color.FromArgb(0xe2, 0xdb, 0xbc);
            this.gridView1.Appearance.FocusedRow.ForeColor = Color.Black;
            this.gridView1.Appearance.FocusedRow.Options.UseBackColor = true;
            this.gridView1.Appearance.FocusedRow.Options.UseBorderColor = true;
            this.gridView1.Appearance.FocusedRow.Options.UseForeColor = true;
            this.gridView1.Appearance.FooterPanel.BackColor = Color.FromArgb(0xd8, 0xd1, 170);
            this.gridView1.Appearance.FooterPanel.BorderColor = Color.FromArgb(0xd8, 0xd1, 170);
            this.gridView1.Appearance.FooterPanel.ForeColor = Color.Black;
            this.gridView1.Appearance.FooterPanel.Options.UseBackColor = true;
            this.gridView1.Appearance.FooterPanel.Options.UseBorderColor = true;
            this.gridView1.Appearance.FooterPanel.Options.UseForeColor = true;
            this.gridView1.Appearance.GroupButton.BackColor = Color.FromArgb(0xd8, 0xd1, 0xb3);
            this.gridView1.Appearance.GroupButton.BorderColor = Color.FromArgb(0xd8, 0xd1, 0xb3);
            this.gridView1.Appearance.GroupButton.Options.UseBackColor = true;
            this.gridView1.Appearance.GroupButton.Options.UseBorderColor = true;
            this.gridView1.Appearance.GroupFooter.BackColor = Color.FromArgb(0xec, 0xe8, 0xc9);
            this.gridView1.Appearance.GroupFooter.BorderColor = Color.FromArgb(0xec, 0xe8, 0xc9);
            this.gridView1.Appearance.GroupFooter.ForeColor = Color.Black;
            this.gridView1.Appearance.GroupFooter.Options.UseBackColor = true;
            this.gridView1.Appearance.GroupFooter.Options.UseBorderColor = true;
            this.gridView1.Appearance.GroupFooter.Options.UseForeColor = true;
            this.gridView1.Appearance.GroupPanel.BackColor = Color.FromArgb(0xf6, 0xf2, 0xd5);
            this.gridView1.Appearance.GroupPanel.BackColor2 = Color.White;
            this.gridView1.Appearance.GroupPanel.ForeColor = Color.Black;
            this.gridView1.Appearance.GroupPanel.Options.UseBackColor = true;
            this.gridView1.Appearance.GroupPanel.Options.UseForeColor = true;
            this.gridView1.Appearance.GroupRow.BackColor = Color.FromArgb(0xec, 0xe8, 0xc9);
            this.gridView1.Appearance.GroupRow.BorderColor = Color.FromArgb(0xec, 0xe8, 0xc9);
            this.gridView1.Appearance.GroupRow.ForeColor = Color.Black;
            this.gridView1.Appearance.GroupRow.Options.UseBackColor = true;
            this.gridView1.Appearance.GroupRow.Options.UseBorderColor = true;
            this.gridView1.Appearance.GroupRow.Options.UseForeColor = true;
            this.gridView1.Appearance.HeaderPanel.BackColor = Color.FromArgb(0xd8, 0xd1, 170);
            this.gridView1.Appearance.HeaderPanel.BorderColor = Color.FromArgb(0xd8, 0xd1, 170);
            this.gridView1.Appearance.HeaderPanel.ForeColor = Color.Black;
            this.gridView1.Appearance.HeaderPanel.Options.UseBackColor = true;
            this.gridView1.Appearance.HeaderPanel.Options.UseBorderColor = true;
            this.gridView1.Appearance.HeaderPanel.Options.UseForeColor = true;
            this.gridView1.Appearance.HideSelectionRow.BackColor = Color.FromArgb(0xed, 230, 0xcb);
            this.gridView1.Appearance.HideSelectionRow.BorderColor = Color.FromArgb(0xed, 230, 0xcb);
            this.gridView1.Appearance.HideSelectionRow.ForeColor = Color.Black;
            this.gridView1.Appearance.HideSelectionRow.Options.UseBackColor = true;
            this.gridView1.Appearance.HideSelectionRow.Options.UseBorderColor = true;
            this.gridView1.Appearance.HideSelectionRow.Options.UseForeColor = true;
            this.gridView1.Appearance.HorzLine.BackColor = Color.FromArgb(0xd8, 0xd1, 170);
            this.gridView1.Appearance.HorzLine.Options.UseBackColor = true;
            this.gridView1.Appearance.OddRow.BackColor = Color.FromArgb(0xf2, 0xf4, 0xec);
            this.gridView1.Appearance.OddRow.BorderColor = Color.FromArgb(0xf2, 0xf4, 0xec);
            this.gridView1.Appearance.OddRow.ForeColor = Color.Black;
            this.gridView1.Appearance.OddRow.Options.UseBackColor = true;
            this.gridView1.Appearance.OddRow.Options.UseBorderColor = true;
            this.gridView1.Appearance.OddRow.Options.UseForeColor = true;
            this.gridView1.Appearance.Preview.BackColor = Color.FromArgb(0xfb, 0xfc, 0xf7);
            this.gridView1.Appearance.Preview.Font = new Font("Verdana", 7.5f);
            this.gridView1.Appearance.Preview.ForeColor = Color.FromArgb(0x94, 0x94, 0x94);
            this.gridView1.Appearance.Preview.Options.UseBackColor = true;
            this.gridView1.Appearance.Preview.Options.UseFont = true;
            this.gridView1.Appearance.Preview.Options.UseForeColor = true;
            this.gridView1.Appearance.Row.BackColor = Color.FromArgb(0xf2, 0xf4, 0xec);
            this.gridView1.Appearance.Row.ForeColor = Color.Black;
            this.gridView1.Appearance.Row.Options.UseBackColor = true;
            this.gridView1.Appearance.Row.Options.UseForeColor = true;
            this.gridView1.Appearance.RowSeparator.BackColor = Color.FromArgb(0xec, 0xe8, 0xc9);
            this.gridView1.Appearance.RowSeparator.BackColor2 = Color.White;
            this.gridView1.Appearance.RowSeparator.Options.UseBackColor = true;
            this.gridView1.Appearance.SelectedRow.BackColor = Color.FromArgb(0xdd, 0xd7, 0xbc);
            this.gridView1.Appearance.SelectedRow.BorderColor = Color.FromArgb(0xed, 230, 0xcb);
            this.gridView1.Appearance.SelectedRow.ForeColor = Color.Black;
            this.gridView1.Appearance.SelectedRow.Options.UseBackColor = true;
            this.gridView1.Appearance.SelectedRow.Options.UseBorderColor = true;
            this.gridView1.Appearance.SelectedRow.Options.UseForeColor = true;
            this.gridView1.Appearance.TopNewRow.BackColor = Color.White;
            this.gridView1.Appearance.TopNewRow.Options.UseBackColor = true;
            this.gridView1.Appearance.VertLine.BackColor = Color.FromArgb(0xd8, 0xd1, 170);
            this.gridView1.Appearance.VertLine.Options.UseBackColor = true;
            this.gridView1.Columns.AddRange(new GridColumn[] { 
                this.gridds_ma, this.gridds_ten, this.gridds_dvt, this.gridds_id, this.gridds_dongia, this.gridds_soluong, this.gridds_thanhtien, this.gridds_idnhapct, this.gridds_slxuat, this.gridds_tenhoatchat, this.gridds_giaban, this.gridds_losx, this.gridds_handung, this.gridds_hangsx, this.gridds_idvitrikho, this.gridds_thue, 
                this.gridds_tongtien, this.gridds_tenvitrikho
             });
            condition.Appearance.ForeColor = Color.Red;
            condition.Appearance.Options.UseForeColor = true;
            condition.Column = this.gridds_dongia;
            condition.Condition = FormatConditionEnum.Between;
            condition.Value1 = "0";
            condition.Value2 = "0";
            this.gridView1.FormatConditions.AddRange(new StyleFormatCondition[] { condition });
            this.gridView1.GridControl = this.gridds;
            this.gridView1.Name = "gridView1";
            this.gridView1.OptionsBehavior.AllowAddRows = DefaultBoolean.True;
            this.gridView1.OptionsBehavior.AllowDeleteRows = DefaultBoolean.False;
            this.gridView1.OptionsBehavior.ReadOnly = true;
            this.gridView1.OptionsView.AutoCalcPreviewLineCount = true;
            this.gridView1.OptionsView.ColumnAutoWidth = false;
            this.gridView1.OptionsView.EnableAppearanceEvenRow = true;
            this.gridView1.OptionsView.EnableAppearanceOddRow = true;
            this.gridView1.OptionsView.ShowAutoFilterRow = true;
            this.gridView1.OptionsView.ShowFooter = true;
            this.gridView1.OptionsView.ShowGroupPanel = false;
            this.gridView1.RowCellStyle += new RowCellStyleEventHandler(this.gridView1_RowCellStyle);
            this.gridView1.CustomSummaryCalculate += new CustomSummaryEventHandler(this.gridView1_CustomSummaryCalculate);
            this.gridView1.FocusedRowChanged += new FocusedRowChangedEventHandler(this.gridView1_FocusedRowChanged);
            this.gridds_ma.Caption = "M\x00e3 số";
            this.gridds_ma.ColumnEdit = this.repositoryItemTextEdit2;
            this.gridds_ma.FieldName = "madp";
            this.gridds_ma.Name = "gridds_ma";
            this.gridds_ma.OptionsColumn.AllowEdit = false;
            this.gridds_ma.Summary.AddRange(new GridSummaryItem[] { new GridColumnSummaryItem(SummaryItemType.Count, "ma", "Cộng: {0:n0}") });
            this.gridds_ma.Visible = true;
            this.gridds_ma.VisibleIndex = 0;
            this.gridds_ma.Width = 0x3d;
            this.gridds_ten.Caption = "T\x00ean dược phẩm";
            this.gridds_ten.ColumnEdit = this.repositoryItemTextEdit2;
            this.gridds_ten.FieldName = "tendp";
            this.gridds_ten.Name = "gridds_ten";
            this.gridds_ten.OptionsColumn.AllowEdit = false;
            this.gridds_ten.Visible = true;
            this.gridds_ten.VisibleIndex = 1;
            this.gridds_ten.Width = 190;
            this.gridds_dvt.Caption = "ĐVT";
            this.gridds_dvt.ColumnEdit = this.repositoryItemTextEdit2;
            this.gridds_dvt.FieldName = "dvt";
            this.gridds_dvt.Name = "gridds_dvt";
            this.gridds_dvt.OptionsColumn.AllowEdit = false;
            this.gridds_dvt.Visible = true;
            this.gridds_dvt.VisibleIndex = 2;
            this.gridds_dvt.Width = 0x27;
            this.gridds_id.Caption = "id";
            this.gridds_id.FieldName = "iddp";
            this.gridds_id.Name = "gridds_id";
            this.gridds_soluong.Caption = "SL";
            this.gridds_soluong.ColumnEdit = this.repositoryItemTextEdit2;
            this.gridds_soluong.FieldName = "soluong";
            this.gridds_soluong.Name = "gridds_soluong";
            this.gridds_soluong.Visible = true;
            this.gridds_soluong.VisibleIndex = 4;
            this.gridds_soluong.Width = 0x25;
            this.gridds_thanhtien.Caption = "Số tiền";
            this.gridds_thanhtien.ColumnEdit = this.repositoryItemTextEdit2;
            this.gridds_thanhtien.FieldName = "thanhtien";
            this.gridds_thanhtien.Name = "gridds_thanhtien";
            this.gridds_thanhtien.Summary.AddRange(new GridSummaryItem[] { new GridColumnSummaryItem(SummaryItemType.Sum, "thanhtien", "Tổng: {0:n0}") });
            this.gridds_thanhtien.Visible = true;
            this.gridds_thanhtien.VisibleIndex = 5;
            this.gridds_thanhtien.Width = 100;
            this.gridds_idnhapct.Caption = "idnhapct";
            this.gridds_idnhapct.FieldName = "id";
            this.gridds_idnhapct.Name = "gridds_idnhapct";
            this.gridds_slxuat.Caption = "sldathanhtoan";
            this.gridds_slxuat.FieldName = "soluongxuat";
            this.gridds_slxuat.Name = "gridds_slxuat";
            this.gridds_tenhoatchat.Caption = "tenhoatchat";
            this.gridds_tenhoatchat.FieldName = "tenhoatchat";
            this.gridds_tenhoatchat.Name = "gridds_tenhoatchat";
            this.gridds_giaban.Caption = "giaban";
            this.gridds_giaban.FieldName = "giaban";
            this.gridds_giaban.Name = "gridds_giaban";
            this.gridds_losx.Caption = "L\x00f4 SX";
            this.gridds_losx.FieldName = "losx";
            this.gridds_losx.Name = "gridds_losx";
            this.gridds_losx.Visible = true;
            this.gridds_losx.VisibleIndex = 8;
            this.gridds_handung.Caption = "Date";
            this.gridds_handung.FieldName = "handung";
            this.gridds_handung.Name = "gridds_handung";
            this.gridds_handung.Visible = true;
            this.gridds_handung.VisibleIndex = 9;
            this.gridds_hangsx.Caption = "hangsx";
            this.gridds_hangsx.FieldName = "hangsx";
            this.gridds_hangsx.Name = "gridds_hangsx";
            this.gridds_idvitrikho.Caption = "idvitrikho";
            this.gridds_idvitrikho.FieldName = "idvitrikho";
            this.gridds_idvitrikho.Name = "gridds_idvitrikho";
            this.gridds_thue.Caption = "Thuế %";
            this.gridds_thue.FieldName = "thue";
            this.gridds_thue.Name = "gridds_thue";
            this.gridds_thue.Visible = true;
            this.gridds_thue.VisibleIndex = 6;
            this.gridds_thue.Width = 0x33;
            this.gridds_tongtien.Caption = "Th\x00e0nh tiền";
            this.gridds_tongtien.ColumnEdit = this.repositoryItemTextEdit2;
            this.gridds_tongtien.FieldName = "tiensauthue";
            this.gridds_tongtien.Name = "gridds_tongtien";
            this.gridds_tongtien.Summary.AddRange(new GridSummaryItem[] { new GridColumnSummaryItem(SummaryItemType.Sum, "tiensauthue", "Tổng: {0:n0}") });
            this.gridds_tongtien.Visible = true;
            this.gridds_tongtien.VisibleIndex = 7;
            this.gridds_tongtien.Width = 0x5f;
            this.gridds_tenvitrikho.Caption = "Vị tr\x00ed trong kho";
            this.gridds_tenvitrikho.FieldName = "tenvitrikho";
            this.gridds_tenvitrikho.Name = "gridds_tenvitrikho";
            this.gridds_tenvitrikho.Visible = true;
            this.gridds_tenvitrikho.VisibleIndex = 10;
            this.gridds_tenvitrikho.Width = 0x107;
            this.gridds.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Top;
            this.gridds.Location = new Point(0, 0x71);
            this.gridds.MainView = this.gridView1;
            this.gridds.Name = "gridds";
            this.gridds.Size = new Size(0x3fe, 0xf5);
            this.gridds.TabIndex = 0x20;
            this.gridds.ViewCollection.AddRange(new BaseView[] { this.gridView1 });
            this.label1.Font = new Font("Tahoma", 10f);
            this.label1.Location = new Point(0x12, 0x1c);
            this.label1.Name = "label1";
            this.label1.Size = new Size(0x5c, 0x13);
            this.label1.TabIndex = 2;
            this.label1.Text = "Số phiếu:";
            this.label1.TextAlign = ContentAlignment.TopRight;
            this.txtsophieu.Location = new Point(0x6b, 0x1b);
            this.txtsophieu.Name = "txtsophieu";
            this.txtsophieu.Properties.CharacterCasing = CharacterCasing.Upper;
            this.txtsophieu.Properties.MaxLength = 10;
            this.txtsophieu.Size = new Size(0x60, 20);
            this.txtsophieu.TabIndex = 0;
            this.txtsophieu.KeyDown += new KeyEventHandler(this.ucDMSanPham_KeyDown);
            this.ctrdanhsach_vp.ChieuRongTuDong = true;
            this.ctrdanhsach_vp.DanhSachCotHienThi = "";
            this.ctrdanhsach_vp.DanhSachCotHienThi_kt = "";
            this.ctrdanhsach_vp.Location = new Point(0x1ba, 0x30);
            this.ctrdanhsach_vp.Name = "ctrdanhsach_vp";
            this.ctrdanhsach_vp.pRowsCountDown = 5;
            this.ctrdanhsach_vp.Size = new Size(60, 0x13);
            this.ctrdanhsach_vp.TabIndex = 14;
            this.ctrdanhsach_vp.Visible = false;
            this.ctrdanhsach_vp.Validated += new EventHandler(this.ctrdanhsach_vp_Validated);
            this.txttenhoatchat.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top;
            this.txttenhoatchat.Location = new Point(0x2f3, 0x1d);
            this.txttenhoatchat.Name = "txttenhoatchat";
            this.txttenhoatchat.Size = new Size(0x109, 20);
            this.txttenhoatchat.TabIndex = 15;
            this.txttenhoatchat.TextChanged += new EventHandler(this.txtten_TextChanged);
            this.txttenhoatchat.Enter += new EventHandler(this.txtten_Enter);
            this.txttenhoatchat.KeyDown += new KeyEventHandler(this.txtten_KeyDown);
            this.txttenhoatchat.Validated += new EventHandler(this.txtten_Validated);
            this.label2.Font = new Font("Tahoma", 10f);
            this.label2.Location = new Point(650, 30);
            this.label2.Name = "label2";
            this.label2.Size = new Size(0x67, 0x13);
            this.label2.TabIndex = 2;
            this.label2.Text = "Hoạt chất:";
            this.label2.TextAlign = ContentAlignment.TopRight;
            this.label14.Font = new Font("Tahoma", 10f);
            this.label14.Location = new Point(7, 0x38);
            this.label14.Name = "label14";
            this.label14.Size = new Size(0x5d, 0x13);
            this.label14.TabIndex = 2;
            this.label14.Text = "Số lượng:";
            this.label14.TextAlign = ContentAlignment.TopRight;
            this.tbnumsoluong.BackColor = Color.White;
            this.tbnumsoluong.DecimalBalance = 0;
            this.tbnumsoluong.Location = new Point(0x60, 0x37);
            this.tbnumsoluong.Name = "tbnumsoluong";
            this.tbnumsoluong.ReadOnly = false;
            this.tbnumsoluong.Size = new Size(0x36, 0x16);
            this.tbnumsoluong.SymbolDecimal = ",";
            this.tbnumsoluong.SymbolThousand = ".";
            this.tbnumsoluong.TabIndex = 0x10;
            this.tbnumsoluong.Texts = "0";
            int[] bits = new int[4];
            this.tbnumsoluong.Values = new decimal(bits);
            this.label19.Font = new Font("Tahoma", 10f);
            this.label19.Location = new Point(0x22, 0x3b);
            this.label19.Name = "label19";
            this.label19.Size = new Size(0x4b, 0x13);
            this.label19.TabIndex = 2;
            this.label19.Text = "Tổng tiền:";
            this.label19.TextAlign = ContentAlignment.TopRight;
            this.tbnumtongtien.BackColor = Color.White;
            this.tbnumtongtien.DecimalBalance = 0;
            this.tbnumtongtien.Enabled = false;
            this.tbnumtongtien.Font = new Font("Tahoma", 12f);
            this.tbnumtongtien.Location = new Point(0x6b, 0x39);
            this.tbnumtongtien.Margin = new Padding(4, 4, 4, 4);
            this.tbnumtongtien.Name = "tbnumtongtien";
            this.tbnumtongtien.ReadOnly = true;
            this.tbnumtongtien.Size = new Size(0x60, 0x16);
            this.tbnumtongtien.SymbolDecimal = ",";
            this.tbnumtongtien.SymbolThousand = ".";
            this.tbnumtongtien.TabIndex = 8;
            this.tbnumtongtien.Texts = "0";
            bits = new int[4];
            this.tbnumtongtien.Values = new decimal(bits);
            this.label20.Font = new Font("Tahoma", 10f);
            this.label20.Location = new Point(0x1b7, 0x3b);
            this.label20.Name = "label20";
            this.label20.Size = new Size(0x49, 0x13);
            this.label20.TabIndex = 2;
            this.label20.Text = "Thực thu:";
            this.label20.TextAlign = ContentAlignment.TopRight;
            this.tbnumtongthucthu.BackColor = Color.White;
            this.tbnumtongthucthu.DecimalBalance = 0;
            this.tbnumtongthucthu.Enabled = false;
            this.tbnumtongthucthu.Font = new Font("Tahoma", 12f);
            this.tbnumtongthucthu.Location = new Point(0x1fb, 0x38);
            this.tbnumtongthucthu.Margin = new Padding(4, 4, 4, 4);
            this.tbnumtongthucthu.Name = "tbnumtongthucthu";
            this.tbnumtongthucthu.ReadOnly = false;
            this.tbnumtongthucthu.Size = new Size(160, 0x16);
            this.tbnumtongthucthu.SymbolDecimal = ",";
            this.tbnumtongthucthu.SymbolThousand = ".";
            this.tbnumtongthucthu.TabIndex = 11;
            this.tbnumtongthucthu.Texts = "0";
            bits = new int[4];
            this.tbnumtongthucthu.Values = new decimal(bits);
            this.btnxoa.Image = Properties.Resources.imgdelete;// (Image)manager.GetObject("btnxoa.Image");
            this.btnxoa.Location = new Point(0xad, 0x53);
            this.btnxoa.Name = "btnxoa";
            this.btnxoa.Size = new Size(0x42, 0x17);
            this.btnxoa.TabIndex = 0x21;
            this.btnxoa.Text = " &X\x00f3a";
            this.btnxoa.Click += new EventHandler(this.btnxoa_Click);
            this.tbnumtongmiengiam.BackColor = Color.White;
            this.tbnumtongmiengiam.DecimalBalance = 0;
            this.tbnumtongmiengiam.Font = new Font("Tahoma", 12f);
            this.tbnumtongmiengiam.Location = new Point(0x163, 0x39);
            this.tbnumtongmiengiam.Margin = new Padding(4, 4, 4, 4);
            this.tbnumtongmiengiam.Name = "tbnumtongmiengiam";
            this.tbnumtongmiengiam.ReadOnly = false;
            this.tbnumtongmiengiam.Size = new Size(0x56, 0x16);
            this.tbnumtongmiengiam.SymbolDecimal = ",";
            this.tbnumtongmiengiam.SymbolThousand = ".";
            this.tbnumtongmiengiam.TabIndex = 10;
            this.tbnumtongmiengiam.Texts = "0";
            bits = new int[4];
            this.tbnumtongmiengiam.Values = new decimal(bits);
            this.label9.Font = new Font("Tahoma", 10f);
            this.label9.Location = new Point(0xcb, 0x3b);
            this.label9.Name = "label9";
            this.label9.Size = new Size(0x54, 0x13);
            this.label9.TabIndex = 2;
            this.label9.Text = "Chiết khấu:";
            this.label9.TextAlign = ContentAlignment.TopRight;
            this.label3.Font = new Font("Tahoma", 10f);
            this.label3.Location = new Point(0x13c, 60);
            this.label3.Name = "label3";
            this.label3.Size = new Size(0x18, 0x13);
            this.label3.TabIndex = 2;
            this.label3.Text = "%";
            this.label3.TextAlign = ContentAlignment.TopRight;
            this.nummiengiam.Font = new Font("Tahoma", 10f);
            this.nummiengiam.Location = new Point(0x11d, 0x39);
            this.nummiengiam.Name = "nummiengiam";
            this.nummiengiam.Size = new Size(0x21, 0x18);
            this.nummiengiam.TabIndex = 9;
            this.nummiengiam.Enter += new EventHandler(this.numthue_Enter);
            this.nummiengiam.KeyDown += new KeyEventHandler(this.ucDMSanPham_KeyDown);
            this.nummiengiam.Validated += new EventHandler(this.nummiengiam_Validated);
            this.label24.Font = new Font("Tahoma", 10f, FontStyle.Bold);
            this.label24.Location = new Point(0x150, 60);
            this.label24.Name = "label24";
            this.label24.Size = new Size(0x13, 0x13);
            this.label24.TabIndex = 2;
            this.label24.Text = "=";
            this.label24.TextAlign = ContentAlignment.TopRight;
            this.label28.Anchor = AnchorStyles.Right | AnchorStyles.Top;
            this.label28.Font = new Font("Tahoma", 10f);
            this.label28.Location = new Point(0xcd, 0x1d);
            this.label28.Name = "label28";
            this.label28.Size = new Size(0x53, 0x13);
            this.label28.TabIndex = 2;
            this.label28.Text = "Nh\x00f3m KH:";
            this.label28.TextAlign = ContentAlignment.TopRight;
            this.cbbnhomkh.Anchor = AnchorStyles.Right | AnchorStyles.Top;
            this.cbbnhomkh.Location = new Point(0x11d, 0x1b);
            this.cbbnhomkh.Name = "cbbnhomkh";
            this.cbbnhomkh.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.cbbnhomkh.Properties.Columns.AddRange(new LookUpColumnInfo[] { new LookUpColumnInfo("id", "id", 20, FormatType.None, "", false, HorzAlignment.Default), new LookUpColumnInfo("ten", "T\x00ean") });
            this.cbbnhomkh.Size = new Size(0x9c, 20);
            this.cbbnhomkh.TabIndex = 7;
            this.cbbnhomkh.KeyDown += new KeyEventHandler(this.ucDMSanPham_KeyDown);
            this.groupControl1.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top;
            this.groupControl1.AppearanceCaption.Font = new Font("Tahoma", 10f, FontStyle.Bold);
            this.groupControl1.AppearanceCaption.Options.UseFont = true;
            this.groupControl1.Controls.Add(this.nummiengiam);
            this.groupControl1.Controls.Add(this.cbbnhomkh);
            this.groupControl1.Controls.Add(this.label3);
            this.groupControl1.Controls.Add(this.label24);
            this.groupControl1.Controls.Add(this.tbnumtongmiengiam);
            this.groupControl1.Controls.Add(this.label28);
            this.groupControl1.Controls.Add(this.tbnumtongthucthu);
            this.groupControl1.Controls.Add(this.label9);
            this.groupControl1.Controls.Add(this.tbnumtongtien);
            this.groupControl1.Controls.Add(this.label20);
            this.groupControl1.Controls.Add(this.txtsophieu);
            this.groupControl1.Controls.Add(this.label19);
            this.groupControl1.Controls.Add(this.label1);
            this.groupControl1.Location = new Point(0, 0x22);
            this.groupControl1.Name = "groupControl1";
            this.groupControl1.Size = new Size(0x400, 0x58);
            this.groupControl1.TabIndex = 40;
            this.groupControl1.Text = "Số phiếu";
            this.groupControl2.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Top;
            this.groupControl2.AppearanceCaption.Font = new Font("Tahoma", 10f, FontStyle.Bold);
            this.groupControl2.AppearanceCaption.Options.UseFont = true;
            this.groupControl2.Controls.Add(this.cbbdonggoi);
            this.groupControl2.Controls.Add(this.gridds);
            this.groupControl2.Controls.Add(this.txtten);
            this.groupControl2.Controls.Add(this.ctrdanhsach_vp);
            this.groupControl2.Controls.Add(this.btnxoa);
            this.groupControl2.Controls.Add(this.label2);
            this.groupControl2.Controls.Add(this.txttenhoatchat);
            this.groupControl2.Controls.Add(this.txtma);
            this.groupControl2.Controls.Add(this.tbnumsoluong);
            this.groupControl2.Controls.Add(this.txtdvt);
            this.groupControl2.Controls.Add(this.label14);
            this.groupControl2.Controls.Add(this.btnthem);
            this.groupControl2.Controls.Add(this.lblmaso);
            this.groupControl2.Location = new Point(0, 0x79);
            this.groupControl2.Name = "groupControl2";
            this.groupControl2.Size = new Size(0x400, 0x166);
            this.groupControl2.TabIndex = 0x29;
            this.groupControl2.Text = "Chi tiết";
            this.cbbdonggoi.Location = new Point(0x9a, 0x37);
            this.cbbdonggoi.Name = "cbbdonggoi";
            this.cbbdonggoi.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.cbbdonggoi.Properties.Columns.AddRange(new LookUpColumnInfo[] { new LookUpColumnInfo("id", "id", 20, FormatType.None, "", false, HorzAlignment.Default), new LookUpColumnInfo("ten", "T\x00ean") });
            this.cbbdonggoi.Size = new Size(0x55, 20);
            this.cbbdonggoi.TabIndex = 0x11;
            this.cbbdonggoi.KeyDown += new KeyEventHandler(this.txtten_KeyDown);
            this.standaloneBarDockControl1.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top;
            this.standaloneBarDockControl1.CausesValidation = false;
            this.standaloneBarDockControl1.Location = new Point(0, 4);
            this.standaloneBarDockControl1.Name = "standaloneBarDockControl1";
            this.standaloneBarDockControl1.Size = new Size(0x400, 0x1c);
            this.standaloneBarDockControl1.Text = "standaloneBarDockControl1";
            this.barManager1.Bars.AddRange(new Bar[] { this.bar1 });
            this.barManager1.DockControls.Add(this.barDockControlTop);
            this.barManager1.DockControls.Add(this.barDockControlBottom);
            this.barManager1.DockControls.Add(this.barDockControlLeft);
            this.barManager1.DockControls.Add(this.barDockControlRight);
            this.barManager1.DockControls.Add(this.standaloneBarDockControl1);
            this.barManager1.Form = this;
            this.barManager1.Items.AddRange(new BarItem[] { this.bbiluu, this.bbiboqua, this.bbiketthuc, this.bbiinphieu, this.barCheckItem1, this.barSubItem1, this.barEditItem1, this.barEditItem2, this.barEditItem3, this.barEditItem4, this.barEditItem5, this.bbixemtruocin, this.barCheckItem2, this.bbithuockhongkedon });
            this.barManager1.MaxItemId = 14;
            this.barManager1.RepositoryItems.AddRange(new RepositoryItem[] { this.repositoryItemCheckEdit1, this.repositoryItemCheckEdit2, this.repositoryItemTextEdit1, this.repositoryItemTextEdit3, this.repositoryItemTextEdit4, this.repositoryItemCheckEdit3, this.repositoryItemCheckEdit4 });
            this.bar1.BarName = "Tools";
            this.bar1.DockCol = 0;
            this.bar1.DockRow = 0;
            this.bar1.DockStyle = BarDockStyle.Standalone;
            this.bar1.FloatLocation = new Point(330, 0x99);
            this.bar1.LinksPersistInfo.AddRange(new LinkPersistInfo[] { new LinkPersistInfo(BarLinkUserDefines.PaintStyle, this.bbiluu, BarItemPaintStyle.CaptionGlyph), new LinkPersistInfo(BarLinkUserDefines.PaintStyle, this.bbiboqua, "", true, true, true, 0, null, BarItemPaintStyle.CaptionGlyph), new LinkPersistInfo(BarLinkUserDefines.PaintStyle, this.bbiinphieu, "", true, true, true, 0, null, BarItemPaintStyle.CaptionGlyph), new LinkPersistInfo(BarLinkUserDefines.PaintStyle, this.bbiketthuc, "", true, true, true, 0, null, BarItemPaintStyle.CaptionGlyph), new LinkPersistInfo(BarLinkUserDefines.PaintStyle, this.bbixemtruocin, "", true, true, true, 0, null, BarItemPaintStyle.CaptionGlyph) });
            this.bar1.OptionsBar.AllowQuickCustomization = false;
            this.bar1.OptionsBar.DrawBorder = false;
            this.bar1.OptionsBar.DrawDragBorder = false;
            this.bar1.StandaloneBarDockControl = this.standaloneBarDockControl1;
            this.bar1.Text = "Tools";
            this.bbiluu.Caption = "&Lưu [F5]";
            this.bbiluu.Glyph = (Image) manager.GetObject("bbiluu.Glyph");
            this.bbiluu.Id = 0;
            this.bbiluu.ItemAppearance.Normal.Font = new Font("Tahoma", 10f);
            this.bbiluu.ItemAppearance.Normal.Options.UseFont = true;
            this.bbiluu.ItemShortcut = new BarShortcut(Keys.F5);
            this.bbiluu.Name = "bbiluu";
            this.bbiluu.ItemClick += new ItemClickEventHandler(this.bbiluu_ItemClick);
            this.bbiboqua.Caption = "&Bỏ qua [F4]";
            this.bbiboqua.Glyph = (Image) manager.GetObject("bbiboqua.Glyph");
            this.bbiboqua.Id = 1;
            this.bbiboqua.ItemAppearance.Normal.Font = new Font("Tahoma", 10f);
            this.bbiboqua.ItemAppearance.Normal.Options.UseFont = true;
            this.bbiboqua.ItemShortcut = new BarShortcut(Keys.F4);
            this.bbiboqua.Name = "bbiboqua";
            this.bbiboqua.ItemClick += new ItemClickEventHandler(this.bbiboqua_ItemClick);
            this.bbiinphieu.Caption = "&In phiếu [F10]";
            this.bbiinphieu.Glyph = (Image) manager.GetObject("bbiinphieu.Glyph");
            this.bbiinphieu.Id = 3;
            this.bbiinphieu.ItemAppearance.Normal.Font = new Font("Tahoma", 10f);
            this.bbiinphieu.ItemAppearance.Normal.Options.UseFont = true;
            this.bbiinphieu.ItemShortcut = new BarShortcut(Keys.F10);
            this.bbiinphieu.Name = "bbiinphieu";
            this.bbiinphieu.ItemClick += new ItemClickEventHandler(this.bbiinphieu_ItemClick);
            this.bbiketthuc.Caption = "&Kết th\x00fac [F12]";
            this.bbiketthuc.Glyph = (Image) manager.GetObject("bbiketthuc.Glyph");
            this.bbiketthuc.Id = 2;
            this.bbiketthuc.ItemAppearance.Normal.Font = new Font("Tahoma", 10f);
            this.bbiketthuc.ItemAppearance.Normal.Options.UseFont = true;
            this.bbiketthuc.ItemShortcut = new BarShortcut(Keys.F12);
            this.bbiketthuc.Name = "bbiketthuc";
            this.bbiketthuc.ItemClick += new ItemClickEventHandler(this.bbiketthuc_ItemClick);
            this.bbixemtruocin.Caption = "&Xem trước khi in";
            this.bbixemtruocin.Edit = this.repositoryItemCheckEdit3;
            this.bbixemtruocin.EditValue = true;
            this.bbixemtruocin.Id = 11;
            this.bbixemtruocin.ItemAppearance.Normal.Font = new Font("Tahoma", 10f);
            this.bbixemtruocin.ItemAppearance.Normal.Options.UseFont = true;
            this.bbixemtruocin.Name = "bbixemtruocin";
            this.bbixemtruocin.Width = 20;
            this.repositoryItemCheckEdit3.AutoHeight = false;
            this.repositoryItemCheckEdit3.Name = "repositoryItemCheckEdit3";
            this.bbithuockhongkedon.Caption = " Thuốc kh\x00f4ng k\x00ea đơn";
            this.bbithuockhongkedon.Edit = this.repositoryItemCheckEdit4;
            this.bbithuockhongkedon.EditValue = false;
            this.bbithuockhongkedon.Glyph = (Image) manager.GetObject("bbithuockhongkedon.Glyph");
            this.bbithuockhongkedon.Id = 13;
            this.bbithuockhongkedon.ItemClickFireMode = BarItemEventFireMode.Postponed;
            this.bbithuockhongkedon.Name = "bbithuockhongkedon";
            this.bbithuockhongkedon.ItemClick += new ItemClickEventHandler(this.bbithuockhongkedon_ItemClick);
            this.repositoryItemCheckEdit4.AutoHeight = false;
            this.repositoryItemCheckEdit4.Name = "repositoryItemCheckEdit4";
            this.barDockControlTop.CausesValidation = false;
            this.barDockControlTop.Dock = DockStyle.Top;
            this.barDockControlTop.Location = new Point(0, 0);
            this.barDockControlTop.Size = new Size(0x400, 0);
            this.barDockControlBottom.CausesValidation = false;
            this.barDockControlBottom.Dock = DockStyle.Bottom;
            this.barDockControlBottom.Location = new Point(0, 0x1e2);
            this.barDockControlBottom.Size = new Size(0x400, 0);
            this.barDockControlLeft.CausesValidation = false;
            this.barDockControlLeft.Dock = DockStyle.Left;
            this.barDockControlLeft.Location = new Point(0, 0);
            this.barDockControlLeft.Size = new Size(0, 0x1e2);
            this.barDockControlRight.CausesValidation = false;
            this.barDockControlRight.Dock = DockStyle.Right;
            this.barDockControlRight.Location = new Point(0x400, 0);
            this.barDockControlRight.Size = new Size(0, 0x1e2);
            this.barCheckItem1.Caption = "Xem trước khi in";
            this.barCheckItem1.Id = 4;
            this.barCheckItem1.ItemAppearance.Normal.Font = new Font("Tahoma", 10f);
            this.barCheckItem1.ItemAppearance.Normal.Options.UseFont = true;
            this.barCheckItem1.Name = "barCheckItem1";
            this.barSubItem1.Caption = "barSubItem1";
            this.barSubItem1.Id = 5;
            this.barSubItem1.LinksPersistInfo.AddRange(new LinkPersistInfo[] { new LinkPersistInfo(this.barEditItem1) });
            this.barSubItem1.Name = "barSubItem1";
            this.barEditItem1.Caption = "barEditItem1";
            this.barEditItem1.Edit = this.repositoryItemCheckEdit1;
            this.barEditItem1.Id = 6;
            this.barEditItem1.Name = "barEditItem1";
            this.repositoryItemCheckEdit1.AutoHeight = false;
            this.repositoryItemCheckEdit1.Name = "repositoryItemCheckEdit1";
            this.barEditItem2.Caption = "barEditItem2";
            this.barEditItem2.Edit = this.repositoryItemCheckEdit2;
            this.barEditItem2.Id = 7;
            this.barEditItem2.Name = "barEditItem2";
            this.repositoryItemCheckEdit2.AutoHeight = false;
            this.repositoryItemCheckEdit2.Name = "repositoryItemCheckEdit2";
            this.barEditItem3.Caption = "barEditItem3";
            this.barEditItem3.Edit = this.repositoryItemTextEdit1;
            this.barEditItem3.Id = 8;
            this.barEditItem3.Name = "barEditItem3";
            this.repositoryItemTextEdit1.AutoHeight = false;
            this.repositoryItemTextEdit1.Name = "repositoryItemTextEdit1";
            this.barEditItem4.Caption = "barEditItem4";
            this.barEditItem4.Edit = this.repositoryItemTextEdit3;
            this.barEditItem4.Id = 9;
            this.barEditItem4.Name = "barEditItem4";
            this.repositoryItemTextEdit3.AutoHeight = false;
            this.repositoryItemTextEdit3.Name = "repositoryItemTextEdit3";
            this.barEditItem5.Caption = "barEditItem5";
            this.barEditItem5.Edit = this.repositoryItemTextEdit4;
            this.barEditItem5.Id = 10;
            this.barEditItem5.Name = "barEditItem5";
            this.repositoryItemTextEdit4.AutoHeight = false;
            this.repositoryItemTextEdit4.Name = "repositoryItemTextEdit4";
            this.barCheckItem2.Caption = "Thuốc kh\x00f4ng k\x00ea đơn";
            this.barCheckItem2.Id = 12;
            this.barCheckItem2.Name = "barCheckItem2";
            base.AutoScaleDimensions = new SizeF(6f, 13f);
            base.AutoScaleMode = AutoScaleMode.Font;
            base.Controls.Add(this.standaloneBarDockControl1);
            base.Controls.Add(this.groupControl2);
            base.Controls.Add(this.groupControl1);
            base.Controls.Add(this.barDockControlLeft);
            base.Controls.Add(this.barDockControlRight);
            base.Controls.Add(this.barDockControlBottom);
            base.Controls.Add(this.barDockControlTop);
            base.Name = "ucd_xuatkho_banle_kkedon_ll";
            base.Size = new Size(0x400, 0x1e2);
            base.Load += new EventHandler(this.ucDMSanPham_Load);
            base.KeyDown += new KeyEventHandler(this.ucDMSanPham_KeyDown);
            this.repositoryItemTextEdit2.EndInit();
            this.txtma.Properties.EndInit();
            this.txtten.Properties.EndInit();
            this.txtdvt.Properties.EndInit();
            this.gridView1.EndInit();
            this.gridds.EndInit();
            this.txtsophieu.Properties.EndInit();
            this.txttenhoatchat.Properties.EndInit();
            this.nummiengiam.EndInit();
            this.cbbnhomkh.Properties.EndInit();
            this.groupControl1.EndInit();
            this.groupControl1.ResumeLayout(false);
            this.groupControl2.EndInit();
            this.groupControl2.ResumeLayout(false);
            this.cbbdonggoi.Properties.EndInit();
            this.barManager1.EndInit();
            this.repositoryItemCheckEdit3.EndInit();
            this.repositoryItemCheckEdit4.EndInit();
            this.repositoryItemCheckEdit1.EndInit();
            this.repositoryItemCheckEdit2.EndInit();
            this.repositoryItemTextEdit1.EndInit();
            this.repositoryItemTextEdit3.EndInit();
            this.repositoryItemTextEdit4.EndInit();
            base.ResumeLayout(false);
        }

        private void nummiengiam_Validated(object sender, EventArgs e)
        {
            try
            {
                this.tbnumtongmiengiam.Values = (this.tbnumtongtien.Values * this.nummiengiam.Value) / 100M;
                this.tbnumtongthucthu.Values = this.tbnumtongtien.Values - this.tbnumtongmiengiam.Values;
            }
            catch
            {
            }
        }

        private void numthue_Enter(object sender, EventArgs e)
        {
        }

        private void tbnumslsang_Validated(object sender, EventArgs e)
        {
            try
            {
            }
            catch
            {
            }
        }

        private void txtma_Validated(object sender, EventArgs e)
        {
            try
            {
                DataRow[] rowArray = this.ctrdanhsach_vp.SetDataSource.Select("ma='" + this.txtma.Text + "'");
                this.f_SetControl_dmsanpham(long.Parse(rowArray[0]["id"].ToString()));
                if (rowArray.Length > 0)
                {
                    this.ctrdanhsach_vp.Visible = false;
                }
            }
            catch
            {
            }
        }

        private void txtten_Enter(object sender, EventArgs e)
        {
            this.ctrdanhsach_vp.Width = (this.txttenhoatchat.Location.X + this.txttenhoatchat.Width) - this.txtma.Location.X;
            this.ctrdanhsach_vp.DanhSachCotHienThi_kt = string.Concat(new object[] { this.txtten.Location.X - this.txtma.Location.X, ",", ((this.ctrdanhsach_vp.Width - 0x55) - this.txtten.Location.X) + this.txtma.Location.X, ",", 30, ",50" });
            this.ctrdanhsach_vp.Location = new Point(this.txtma.Location.X, (this.txtma.Location.Y + this.txtma.Height) + 1);
            this.ctrdanhsach_vp.BringToFront();
        }

        private void txtten_KeyDown(object sender, KeyEventArgs e)
        {
            if ((e.KeyCode == Keys.Up) || (e.KeyCode == Keys.Down))
            {
                if (this.ctrdanhsach_vp.Visible)
                {
                    this.ctrdanhsach_vp.Focus();
                }
            }
            else if (e.KeyCode == Keys.Escape)
            {
                this.ctrdanhsach_vp.Visible = false;
            }
            else
            {
                this.ctrdanhsach_vp.Visible = false;
                this.ucDMSanPham_KeyDown(sender, e);
            }
        }

        private void txtten_TextChanged(object sender, EventArgs e)
        {
            try
            {
                if (this.txtten.IsEditorActive)
                {
                    this.ctrdanhsach_vp.Visible = true;
                    this.ctrdanhsach_vp.Locdulieu(this.txtten.Text);
                }
            }
            catch
            {
            }
        }

        private void txtten_Validated(object sender, EventArgs e)
        {
            try
            {
            }
            catch
            {
            }
        }

        private void ucDMSanPham_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                SendKeys.Send("{Tab}");
            }
            else if ((e.KeyCode == Keys.F2) && this.btnthem.Enabled)
            {
                this.btnmoi_Click(null, null);
            }
        }

        private void ucDMSanPham_Load(object sender, EventArgs e)
        {
            this.txtsophieu.Properties.ReadOnly = true;
            this._xuatban = new DXuatBanLe(this._xuli.pConFigData);
            this.f_load_nhomkh();
            if (this._dtobanle.pID == 0L)
            {
                this.btnmoi_Click_1(null, null);
            }
            else
            {
                this.f_Loaddata_dmvp();
                this.f_setcontrol_xuatbanle(this._dtobanle.pID);
                this.f_loaddata_xuatbanlect(this._dtobanle.pID);
                this.f_loadinfo_chidinhchitiet(0);
                this.btnsua_Click(null, null);
                this.txtma.Focus();
            }
        }
    }
}

